{include file="index/header" /}
<body>
	<div class="panel admin-panel margin-top" id="add">
		<div class="panel-head"><strong><span class="icon-pencil-square-o"></span> 增加内容</strong></div>
		<div class="body-content">
			<form method="post" class="form-x" action=""  enctype="multipart/form-data">    
				<div class="form-group">
					<div class="label">
						<label>名称：</label>
					</div>
					<div class="field">
						<input type="text" class="input w50" value="{$s_data.s_name}" name="s_name" data-validate="required:请输入标题"/>
						<div class="tips"></div>
					</div>
				</div>
				<div class="form-group">
					<div class="label">
						<label>是否在前台页面展示：</label>
					</div>
					<div class="field">
						<div class="button-group radio">
							<label class="button {if  !$s_data || $s_data.s_show eq 1} active {/if}">
								<span class="icon icon-check"></span>
								<input name="s_show" value="1" type="radio" {if $s_data.s_show eq 1}  checked="checked" {/if}>是
							</label>
							<label class="button {if $s_data && $s_data.s_show eq 0} active {/if}">
								<span class="icon icon-times"></span>
								<input name="s_show" value="0"  type="radio" {if $s_data.s_show eq 0}  checked="checked" {/if}>否
							</label>
						</div>
					</div>
				</div>
				<div class="form-group">
					<div class="label">
						<label>是否免费：</label>
					</div>
					<div class="field">
						<div class="button-group radio">
							<label class="button {if  $s_data.s_free eq 1} active {/if}">
								<span class="icon icon-check"></span>
								<input name="s_free" value="1" type="radio" {if $s_data.s_free eq 1}  checked="checked" {/if}>是
							</label>
							<label class="button {if $s_data.s_free eq 0} active {/if}">
								<span class="icon icon-times"></span>
								<input name="s_free" value="0"  type="radio" {if $s_data.s_free eq 0}  checked="checked" {/if}>否
							</label>
						</div>
					</div>
				</div>
				<div class="form-group">
					<div class="label">
						<label>分类标题：</label>
					</div>
					<div class="field">
						<select name="nav_id" class="input w50" id="nav" data-validate="required:请选择课程">
							<option value="">请选择课程</option>
							{foreach name='nav_data' item='nav'}
							<option value="{$nav.nav_id}" {if $nav.nav_id eq $s_data.nav_id} selected=""{/if}>{$nav.nav_name}</option>
							{/foreach}
						</select>  
						<select name="type_id" class="input w50" id="type" data-validate="required:请选择阶段">
							<option value="">请选择阶段</option>
							{foreach name='type_data' item='type'}
							<option value="{$type.type_id}" {if $s_data.type_id eq $type.type_id}selected{/if}>{$type.type_name}</option>
							{/foreach}
						</select>
						<div class="tips"></div>
					</div>
				</div>
				<div class="form-group">
					<div class="label">
						<label>排序：</label>
					</div>
					<div class="field">
						<input type="text" class="input w50" name="s_sort" value="{$s_data.s_sort ?: 0}"  data-validate="required:,number:排序必须为数字" />
						<div class="tips"></div>
					</div>
				</div>
				<div class="form-group">
					<div class="label">
						<label></label>
					</div>
					<div class="field">
						<button class="button bg-main icon-check-square-o" type="submit"> 提交</button>
					</div>
				</div>
			</form>
		</div>
	</div>
</body></html>
<script>
	$('#nav').change(function(){
		var nav_id = $(this).val();
		$("#type option:gt(0)").remove();
		if(nav_id == ''){
			return;
		}
		$.ajax({
			type:'GET',
			url :"{:url('getType')}",
			data:'nav_id='+nav_id,
			dataType:'json',
			success : function(data){
				$.each(data, function(k,v){
					$('#type').append('<option value="'+v.type_id+'">'+v.type_name+'</option>');
				});
			}
		});
	});
</script>